package org.yx.service.smfr.view_product_sn_to_print_label;

import com.xiaoleilu.hutool.util.StrUtil;
import org.yx.service.smat.view_material_sn_to_print_label.SmatViewMaterialSnToPrintLabelOut;
import org.yx.utils.BaseService;
import yxmes.tools.FineReportUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @author zxw
 * @since 2023/03/23
**/
public class SmfrViewProductSnToPrintLabelService extends BaseService {
	public SmfrViewProductSnToPrintLabelOut viewProductSnToPrintLabel(SmfrViewProductSnToPrintLabelIn in) throws Exception {
		Map<String, Object> mapParm = new HashMap<String, Object>();
		String[] psns = StrUtil.removeSuffix(in.getPsns(),",").split(",");
		String psn = StrUtil.join("','", (Object[]) psns);
		psn = StrUtil.addPrefixIfNot(psn,"'");
		psn = StrUtil.addSuffixIfNot(psn,"'");
		mapParm.put("psn", psn);
		mapParm.put("orgCode",in.getUserOrgCode());

		SmfrViewProductSnToPrintLabelOut out = new SmfrViewProductSnToPrintLabelOut();
		out.setFileName(FineReportUtil.printDataToPdf(mapParm, in.getUserOrgCode() + "_product_label.cpt").getName());

		return out;
	}
}